<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<view class="text-area">
			<text class="title">{{title}}</text>
		</view>
		<navigator url="/pages/404/404">404页面</navigator>
		<navigator url="/subpages/chat/chat">在线聊天</navigator>
		<Child :msg="pMsg" @childEvent="sayHello"></Child>
	</view>
</template>

<script>
	import Child from '@/components/child.vue'
	export default {
		components:{
			Child // 引入子组件
		},
		data() {
			return {
				title: '首页',
				pMsg: '我是父组件定义的信息-父传子'
			}
		},
		onShow() {
			console.log('首页加载成功')
		},
		onLoad() {
			// 获取当前页面栈
			console.log(getCurrentPages());
			
			// 判断客户端环境是 Android、iOS 还是小程序开发工具
			switch(uni.getSystemInfoSync().platform){
			   case 'android':
			      console.log('运行Android上')
			      break;
			   case 'ios':
			      console.log('运行iOS上')
			      break;
			   default:
			      console.log('运行在开发者工具上')
			      break;
			}
		},
		onPullDownRefresh() {
			console.log('页面下拉刷新成功')
		},
		methods: {
			sayHello(val){
				this.title = "子组件发送信息给父组件"+'---'+val;
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
